import org.apache.commons.lang3.*;
import java.util.*;

public class List2 {

	public void aList(int size,int remove) {

		ArrayList<String> aL = new ArrayList<String>();
		for (int i = 0; i < size; i++)
			aL.add(RandomStringUtils.random(10, "abcdefghijklmnopqrstuvwxyz"));
		/*
		java.util.Iterator<String> iterator = aL.iterator();

		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}*/
		aL.remove(remove);
		/*
		System.out.println();
		System.out.println("After removing");
		System.out.println();
		
		iterator = aL.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}
		*/
		//return aL;

	}

	public void lList(int size,int remove) {

		LinkedList<String> lL = new LinkedList<String>();
		for (int i = 0; i < size; i++)
			lL.add(RandomStringUtils.random(10, "abcdefghijklmnopqrstuvwxyz"));
		java.util.Iterator<String> iterator = lL.iterator();
		/*
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}*/
		lL.remove(remove);
		/*
		System.out.println();
		System.out.println("After removing");
		System.out.println();
		
		iterator = lL.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}

		*/
		//return lL;

	}

	public long benchLinkedList() {

		long start = System.currentTimeMillis();
		aList(100,10);
		long end = System.currentTimeMillis();

		return end - start;
	}

	public long benchArrayList() {

		long start = System.currentTimeMillis();
		lList(100,10);
		long end = System.currentTimeMillis();

		return end - start;
	}

	public static void main(String[] args) {

		List2 l = new List2();
		System.out.println("Time taken for ArrayList : " + l.benchArrayList());
		
		System.out.println();
		System.out.println("Time taken for LinkedList:  " + l.benchArrayList());
	}

}
